package com.edevp.common.core.logback.converter;

import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import com.edevp.common.core.util.CommonUtil;
import com.edevp.common.core.util.session.SessionUtil;

/**
 * logback 扩展属性
 * @author Blueeyedboy
 * @date 2022-07-06 6:48 PM
 **/
public class ClientIpConverter extends ClassicConverter {
	@Override
	public String convert(ILoggingEvent event) {
		String ip = SessionUtil.getClientIpAddr();
		if(CommonUtil.isNull(ip)){
			ip = "127.0.0.1";
		}
		return ip;
	}
}